package 剑指offer;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

public class _31栈的弹入弹出序列 {
    /*public static boolean validateStackSequences(int[] pushed, int[] popped) {
        if (pushed.length == 0 && popped.length == 0){
            return true;
        }
        Deque<Integer> deque = new LinkedList();
        int j = 1;
        deque.push(pushed[0]);
        for (int i = 0; i < popped.length; i++){
            while (deque.peek() != popped[i]){
                if(j >= pushed.length){
                    return false;
                }
                deque.push(pushed[j]);
                j++;
            }
            deque.poll();
        }
        return true;
    }*/
    /*public boolean validateStackSequences(int[] pushed, int[] popped) {
        Stack<Integer> stack = new Stack<>();
        int i = 0;
        for(int num : pushed) {
            stack.push(num);
            while(!stack.isEmpty() && stack.peek() == popped[i]) {
                stack.pop();
                i++;
            }
        }
        return stack.isEmpty();
    }*/
}
